<?php
include 'inc/header.php';

title('可变标识符');

comment('可变变量');
$color = 'pink';
$name = 'color';
clog($$name); // pink

$varname = "english";
$$varname = 90;
clog(($english)); // 90

comment('可变函数');

function func()
{
    clog('hello!');
}
$funName = 'func';
$funName(); // hello

comment('可变类名');
class Person
{
    public $word = 'hello';
}
$className = 'Person';
$person = new $className;
echo $person->word;

comment('可变属性');

class Person2
{
    public $word2 = 'hello2';
}
$className = 'Person2';
$person2 = new $className;
$prop = 'word2';
echo $person2->$prop;

comment('可变方法');
class Car
{
    public function run()
    {
        clog("car is running...");
    }
}
$car = new Car;
$method = 'run';
$car->$method();

include 'inc/footer.php';